<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<style type="text/css">
			html,body { height:100%; }
			.detial_news .title{ position: relative; padding: 20px 15px; color: #333;}
			.detial_news .title h1{ display:block; font-size: 18px; font-weight: 600; line-height: 25px;}
			.detial_news .title p{ font-size: 12px; color:#9F9F9F; padding-top: 10px;}
			.detial_news .con{ padding: 0px 15px; font-size: 15px; color: #333; line-height: 27px;}
			.detial_news .con p1{ text-indent: 2em;}
			.detial_news .con img{ width: 100%; margin: 7px 0; border-radius: 0.3px;}
			.sk-three-bounce {
			  margin: 0 auto;
			  width: 80px;
			  text-align: center; }
			  .sk-three-bounce .sk-child {
				width: 13.5px;
				height: 13.5px;
				background-color: #3262F1;
				border-radius: 100%;
				display: inline-block;
				-webkit-animation: sk-three-bounce 1.4s ease-in-out 0s infinite both;
						animation: sk-three-bounce 1.4s ease-in-out 0s infinite both; }
			  .sk-three-bounce .sk-bounce1 {
				-webkit-animation-delay: -0.32s;
						animation-delay: -0.32s; }
			  .sk-three-bounce .sk-bounce2 {
				-webkit-animation-delay: -0.16s;
						animation-delay: -0.16s; }

			@-webkit-keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); } }

			@keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); }
			}
		</style>
	</head>
	<body>
		<div class="detial_news" id="detail_news">

		</div>
		<script id="newsdetail_template" type="text/template">
			<ul class="title">
				<h1>{{=it.title}}</h1>
				<p>{{=it.createtime}}</p>
			</ul>
			<ul class="con">
				<p>{{=it.newscontent}}</p>
			</ul>
			</script>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/app.js"></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript">
		var bannerid;
		var UILoading;
		apiready = function() {
			api.parseTapmode();
			UILoading = api.require('UILoading');
			$api.css($api.dom('.detial_news'), 'display: none');
			showloading();
			bannerid = api.pageParam.bannerid;
			getJsonFromAPI();
			api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'left') {
					api.closeWin({
					});
                }
            });
		}
		
		function getJsonFromAPI() {
			//从接口获取查询数据
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/bannerdetail/'+bannerid,
						method: 'get',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						}
					}, function(ret, err) {
						hideloading();
						$api.css($api.dom('.detial_news'), 'display: block');
						if (ret) {
							var newsdetail = ret.news;
							UpdateList('detail_news','newsdetail_template',newsdetail);
							

						} else {
							if(err.statusCode==402)
							{
								Relogin();
							}
							else
							{
								//api.alert({ msg: '文章已删除' });
								console.log(JSON.stringify(err));
							}
						}
					});
				}
			});
		}
		//渲染数据
		function UpdateList(domId,templateId,jsondata) {
			console.log(JSON.stringify(jsondata));
			var act_content = $api.byId(domId);
			var tempFn = doT.template($api.byId(templateId).innerHTML);
			var resultText = tempFn(jsondata);
			$api.html(act_content, resultText);
			api.parseTapmode();
		}
	</script>
</html>